package com.paradogs.framework.core.queue;

import com.paradogs.framework.core.msg.ByteData;
import com.paradogs.framework.core.msg.PRMsgContextHolder;
import com.paradogs.framework.core.netty.events.MainLoopEvent;
import com.paradogs.framework.core.utils.EventUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;

/**
 * @author: yumi
 * @date: 2023/11/6  17:35
 * @Description: TODO
 */
@Slf4j
public abstract class AbstractMsgConsumer extends QueueConsumerThread<ByteData> {

    private MainLoopEvent mainLoopEvent = new MainLoopEvent();

    @Override
    public void loop() {
        EventUtils.publishEvent(mainLoopEvent);
    }

    @Override
    public void handleBefore(ByteData msg) {
        super.handleBefore(msg);
        PRMsgContextHolder.setContext(msg.getContext());
    }
}
